﻿using System;
using System.Collections.Generic;
using System.Data;
using DAL;
using Entities;


namespace BLL
{
    public class BLL_Cook
    {
        private DAL_Cook dal_Cook = new DAL_Cook();

        public DataTable Get_Cook_All()
        {
            return dal_Cook.Get_Cook_All();
        }

        public DataTable Get_CookTop()
        {
            return dal_Cook.Get_CookTop();
        }

        public DataTable Get_Cook_ByID(int p_cook_id)
        {
            return dal_Cook.Get_Cook_ByID(p_cook_id);
        }

        public DataSet Get_CookDetail(int p_cook_id)
        {
            return dal_Cook.Get_CookDetail(p_cook_id);
        }
        
        public List<Cook> Lst_Cook(DataTable pdt)
        {
            List<Cook> lstReturn = new List<Cook>();
            if (pdt != null && pdt.Rows.Count > 0)
            {
                foreach (DataRow dr in pdt.Rows)
                {
                    Cook obj_Cook = new Cook();
                    obj_Cook.COOK_ID = Convert.ToInt32(dr["Cook_id"]);
                    obj_Cook.TITLE = Convert.ToString(dr["Title"]);
                    obj_Cook.CONTENT_DESC = Convert.ToString(dr["Content_desc"]);
                    obj_Cook.CONTENT_DETAIL = Convert.ToString(dr["Content_detail"]);
                    obj_Cook.IMAGE_DATA = dr["Image_data"] == DBNull.Value ? null : (byte[])(dr["Image_data"]);
                    lstReturn.Add(obj_Cook);
                }
            }
            return lstReturn;
        }

        public Int32 InsertCook(Cook pCook)
        {
            return dal_Cook.InsertCook(pCook);
        }

        public bool UpdateCook(Cook pCook)
        {
            return dal_Cook.UpdateCook(pCook);
        }

        public bool UpdateCookNotImage(Cook pCook)
        {
            return dal_Cook.UpdateCookNotImage(pCook);
        }

        public bool DeleteCook(int p_cook_id)
        {
            return dal_Cook.DeleteCook(p_cook_id);
        }
    }
}
